import 'dart:convert';

List<ProgramBookList> programBookListsFromJson(String str) =>
    List<ProgramBookList>.from(
        json.decode(str).map((x) => ProgramBookList.fromJson(x)));

String programBookListsToJson(List<ProgramBookList> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class ProgramBookList {
  ProgramBookList({
    this.name,
    this.id,
    this.lowerProgram,
    this.bookList,
  });

  String? name;
  String? id;
  List<ProgramBookList>? lowerProgram;
  List<BookList>? bookList;

  factory ProgramBookList.fromJson(Map<String, dynamic> json) =>
      ProgramBookList(
        name: json["name"],
        id: json["id"],
        bookList: json["bookList"] == null
            ? null
            : List<BookList>.from(
                json["bookList"].map((x) => BookList.fromJson(x))),
        lowerProgram: json["lowerProgram"] != null
            ? List<ProgramBookList>.from(
                json["lowerProgram"].map((x) => ProgramBookList.fromJson(x)))
            : null,
      );

  Map<String, dynamic> toJson() => {
        "name": name,
        "id": id,
        "bookList": bookList == null
            ? null
            : List<dynamic>.from(bookList!.map((x) => x.toJson())),
        "lowerProgram": lowerProgram != null
            ? List<dynamic>.from(lowerProgram!.map((x) => x.toJson()))
            : null,
      };
}

// class ProgramBookListLowerProgram {
//   ProgramBookListLowerProgram({
//     this.name,
//     this.id,
//     this.lowerProgram,
//     this.bookList,
//   });

//   String? name;
//   String? id;
//   List<BookList>? bookList;
//   List<LowerProgram>? lowerProgram;

//   factory ProgramBookListLowerProgram.fromJson(Map<String, dynamic> json) =>
//       ProgramBookListLowerProgram(
//         name: json["name"],
//         id: json["id"],
//         bookList: json["bookList"] == null
//             ? null
//             : List<BookList>.from(
//                 json["bookList"].map((x) => BookList.fromJson(x))),
//         lowerProgram: json["lowerProgram"] != null
//             ? List<LowerProgram>.from(
//                 json["lowerProgram"].map((x) => LowerProgram.fromJson(x)))
//             : null,
//       );

//   Map<String, dynamic> toJson() => {
//         "name": name,
//         "id": id,
//         "bookList": bookList == null
//             ? null
//             : List<dynamic>.from(bookList!.map((x) => x.toJson())),
//         "lowerProgram": lowerProgram != null
//             ? List<dynamic>.from(lowerProgram!.map((x) => x.toJson()))
//             : null,
//       };
// }

// class LowerProgram {
//   LowerProgram({
//     this.name,
//     this.id,
//     this.bookList,
//     this.lowerProgram,
//   });

//   String? name;
//   String? id;
//   List<BookList>? bookList;
//   List<LowerProgram>? lowerProgram;

//   factory LowerProgram.fromJson(Map<String, dynamic> json) => LowerProgram(
//         name: json["name"],
//         id: json["id"],
//         bookList: json["bookList"] == null
//             ? null
//             : List<BookList>.from(
//                 json["bookList"].map((x) => BookList.fromJson(x))),
//         lowerProgram: json["lowerProgram"] == null
//             ? null
//             : List<LowerProgram>.from(
//                 json["lowerProgram"].map((x) => LowerProgram.fromJson(x))),
//       );

//   Map<String, dynamic> toJson() => {
//         "name": name,
//         "id": id,
//         "bookList": bookList == null
//             ? null
//             : List<dynamic>.from(bookList!.map((x) => x.toJson())),
//         "lowerProgram": lowerProgram == null
//             ? null
//             : List<dynamic>.from(lowerProgram!.map((x) => x.toJson())),
//       };
// }

class BookList {
  BookList(
      {this.traditionalTitle,
      this.bookId,
      this.bookTitle,
      this.quizAvailable,
      this.inFolder,
      this.bookCode,
      this.selected,
      this.viewMode});

  String? traditionalTitle;
  String? bookId;
  String? bookTitle;
  bool? quizAvailable;
  bool? inFolder;
  String? bookCode;
  bool? selected;
  String? viewMode;

  factory BookList.fromJson(Map<String, dynamic> json) => BookList(
        traditionalTitle: json["traditionalTitle"],
        bookId: json["bookId"],
        bookTitle: json["bookTitle"],
        quizAvailable: json["quizAvailable"],
        inFolder: json["inFolder"],
        bookCode: json["bookCode"],
        selected: json["selected"],
        viewMode: json["viewMode"],
      );

  Map<String, dynamic> toJson() => {
        "traditionalTitle": traditionalTitle,
        "bookId": bookId,
        "bookTitle": bookTitle,
        "quizAvailable": quizAvailable,
        "inFolder": inFolder,
        "bookCode": bookCode,
        "selected": selected,
        "viewMode": viewMode
      };
}
